const axios = require('axios');
const config = require('../config');
const {AxiosError} = require("axios");

class Http {
    instance = null;

    constructor() {
        this.instance = axios.create({
            baseURL: config.nacosApi.baseUrl,
            timeout: 10000,
            headers: {
                "Content-Type": "application/json"
            }
        })

        this.ResponseInterceptor();
    }


    async get(params) {
        return await this.instance.get(params.url, {
            params: params.data,
        });
    }

    async ResponseInterceptor() {
        this.instance.interceptors.response.use(
            (response) => {
                return response.data;
            },
            (error) => {
                return Promise.reject(error)
            })
    }
}

module.exports = new Http